<%@ page language="java" import="java.util.*,java.util.Date,java.sql.*,java.text.SimpleDateFormat" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<jsp:useBean id="db" class="connBean.ConnDB" scope="page" />

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'addComments.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
      <%request.setCharacterEncoding("utf-8");
       String  p_id=request.getParameter("p_id");
       String content=request.getParameter("content");
       
       SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格
       String date=df.format(new Date());// new Date()为获取当前系统时间
       db.OpenConn();
       db.createStmt();
       String sql="insert into comment(c_id,p_id,cm_message,cm_time) values("+session.getAttribute("userid")+",'"+p_id+"','"+content+"','"+date+"')";
       System.out.println(sql);
       int result=db.Update(sql);
       if(result!=0)
       {
       response.sendRedirect("index_ProductDetail.jsp?p_id="+p_id);
       }else
       {
       out.print("插入失败,3秒后返回");
       response.setHeader("Refresh","3,URL=index_ProductDetail.jsp?p_id="+p_id);
       }
       %>
  </body>
</html>
